// Future<void> fetchUserOrder() {
//   // Imagine that this function is fetching user info from another service or database.
//   return Future.delayed(const Duration(seconds: 2), () => print('Large Latte'));
// }

// Future<void> fetchUserOrder2() {
// // Imagine that this function is fetching user info but encounters a bug
//   return Future.delayed(const Duration(seconds: 2),
//       () => throw Exception('Logout failed: user ID is invalid'));
// }

// void main() {
//   fetchUserOrder2();
//   print('Fetching user order...');
// }

Future<String> fetchNewUsername() {
  return Future.delayed(
      const Duration(seconds: 2), () => throw Exception('error: no user'));
}

Future<String> changeUsername() async {
  try {
    var user = await fetchNewUsername();
    print(user.toString());
    return user;
  } catch (err) {
    print(err.toString());
    return err.toString();
  }
}

Future<void> main() async {
  changeUsername();
}
